home *** CD-ROM | disk | FTP | other *** search
/ Aminet 50 / Aminet 50 (2002)(GTI - Schatztruhe)[!][Aug 2002].iso / Aminet / text / edit / tecoc-146.lha / exescl.c < prev    next >
C/C++ Source or Header  |  1991-07-05  |  2KB  |  63 lines

  1. /*****************************************************************************
  2.  
  3.     ExeSCl()
  4.  
  5.     This function executes a semi-colon (;) command.
  6.  
  7.     ;    Exit iteration on search failure
  8.     n;    Exit iteration if n is positive
  9.     :;    Exit iteration on search success
  10.     n:;    Exit iteration if n is negative
  11. *****************************************************************************/
  12.  
  13. #include "zport.h"        /* define portability identifiers */
  14. #include "tecoc.h"        /* define general identifiers */
  15. #include "defext.h"        /* define external global variables */
  16. #include "deferr.h"        /* define identifiers for error messages */
  17.  
  18. DEFAULT ExeSCl()            /* execute semi-colon command */
  19. {
  20. #if DEBUGGING
  21.     static char *DbgFNm = "ExeSCl";
  22.     DbgFEn(1,DbgFNm,
  23.         (CmdMod & COLON)
  24.             ? (EStTop == EStBot) ? "have :;" : "have n:;"
  25.             : (EStTop == EStBot) ? "have ;"  : "have n;"   );
  26. #endif
  27.     if (LStTop == LStBot) {            /* if not in a loop */
  28.         ErrMsg(ERR_SNI);        /* ; not in iteration */
  29.         DBGFEX(1,DbgFNm,"FAILURE");
  30.         return FAILURE;
  31.     }
  32.  
  33.     if (EStTop == EStBot) {            /* if no numeric argument */
  34.         ErrMsg(ERR_NAS);        /* no argument before ; */
  35.         DBGFEX(1,DbgFNm,"FAILURE");
  36.         return FAILURE;
  37.     }
  38.  
  39.     if (GetNmA() == FAILURE) {        /* get numeric argument */
  40.         DBGFEX(1,DbgFNm,"FAILURE. GetNmA failed()");
  41.         return FAILURE;
  42.     }
  43.  
  44. /*
  45.  * If not colon-modified and numeric arg is positive OR
  46.  *    if colon-modified and numeric arg is negative
  47.  *    flow to the end of the loop and exit it
  48.  */
  49.     if ( (!(CmdMod & COLON) && (NArgmt >= 0) ) ||
  50.          ( (CmdMod & COLON) && (NArgmt <  0) ) ) {
  51.         if (FlowEL() == FAILURE) {    /* flow to end of loop */
  52.             DBGFEX(1,DbgFNm,"FAILURE, FlowEL() failed");
  53.             return FAILURE;
  54.         }
  55.     }
  56.  
  57.     CmdMod = '\0';                /* clear modifiers flags */
  58.     EStTop = EStBot;            /* clear expression stack */
  59.  
  60.     DBGFEX(1,DbgFNm,"SUCCESS");
  61.     return SUCCESS;
  62. }
  63.